<html>
  <head>
    <title>Using the DxValidateColumnProvider</title>
    <link rel="stylesheet" type="text/css" href="../../styles/presentation.css" />
    <link rel="stylesheet" type="text/css" href="ms-help://Hx/HxRuntime/HxLink.css" />
    <script type="text/javascript" src="../../scripts/EventUtilities.js"></script>
    <script type="text/javascript" src="../../scripts/SplitScreen.js"></script>
    <script type="text/javascript" src="../../scripts/Dropdown.js"></script>
    <script type="text/javascript" src="../../scripts/script_loc.js"></script>
    <script type="text/javascript" src="../../scripts/script_manifold.js"></script>
    <script type="text/javascript" src="../../scripts/script_feedBack.js"></script>
    <script type="text/javascript" src="../../scripts/CheckboxMenu.js"></script>
    <script type="text/javascript" src="../../scripts/CommonUtilities.js"></script>
  </head>
  <body>
    <input type="hidden" id="userDataCache" class="userDataStyle" />
    <input type="hidden" id="hiddenScrollOffset" />
    <img id="collapseImage" style="display:none; height:0; width:0;" src="../../icons/collapse_all.gif" title="Collapse image" />
    <img id="expandImage" style="display:none; height:0; width:0;" src="../../icons/expand_all.gif" title="Expand Image" />
    <img id="collapseAllImage" style="display:none; height:0; width:0;" src="../../icons/collapse_all.gif" />
    <img id="expandAllImage" style="display:none; height:0; width:0;" src="../../icons/expand_all.gif" />
    <img id="dropDownImage" style="display:none; height:0; width:0;" src="../../icon/dropdown.gif" />
    <img id="dropDownHoverImage" style="display:none; height:0; width:0;" src="../../icons/dropdownHover.gif" />
    <img id="copyImage" style="display:none; height:0; width:0;" src="../../icons/copycode.gif" title="Copy image" />
    <img id="copyHoverImage" style="display:none; height:0; width:0;" src="../../icons/copycodeHighlight.gif" title="CopyHover image" />
    <div id="header">
      <table id="topTable" cellspacing="0" cellpadding="0">
        <tr>
          <td>
            <span onclick="ExpandCollapseAll(toggleAllImage)" style="cursor:default;" onkeypress="ExpandCollapseAll_CheckKey(toggleAllImage, event)" tabindex="0">
              <img ID="toggleAllImage" class="toggleAll" src="../../icons/collapse_all.gif" />
              <label id="collapseAllLabel" for="toggleAllImage" style="display: none;">Collapse All</label>
              <label id="expandAllLabel" for="toggleAllImage" style="display: none;">Expand All</label>
            </span>
          </td>
        </tr>
      </table>
      <table id="bottomTable" cellpadding="0" cellspacing="0">
        <tr id="headerTableRow1">
          <td align="left">
            <span id="runningHeaderText">DevExpress Contrib</span>
          </td>
        </tr>
        <tr id="headerTableRow2">
          <td align="left">
            <span id="nsrTitle">
                  Using the DxValidateColumnProvider
               </span>
          </td>
          <td align="center" style="width: 1px; padding: 0px">
            <img src="../../images/DevExContrib 32.png" alt="DevExpress Contrib" />
          </td>
        </tr>
        <tr id="headerTableRow3">
          <td align="left">
            <span id="headfb" class="feedbackhead" />
          </td>
        </tr>
      </table>
      <table id="gradientTable">
        <tr>
          <td class="nsrBottom" background="../../icons/gradient.gif" />
        </tr>
      </table>
    </div>
    <div id="mainSection">
      <div id="mainBody">
        <div class="Content">
          <p>Unlike the DxValidationProvider, the DxValidateColumnProvider must be instantiated programmatically.</p>
          <pre lang="cs" numberLines="true" outlining="true" title="Instantiating the DxValidateColumnProvider">
   private DxValidateColumnProvider validateColumn;
   ...
   validateColumn = new DxValidateColumnProvider(true, gridView);</pre>
          <p>In this example a new DxValidateColumnProvider is instantiated. The first parameter tells the provider
          to run each of the individual column validators immediately before the row loses focus. The second parameter
          is a view to register with the provider. Multiple views can be passed to the constructor.</p>
          <p>Views can also be added outside of the constructor.</p>
          <pre lang="cs" numberLines="true" outlining="true" title="Adding column rules to the DxValidateColumnProvider">
   validateColumn.AddView(layoutView);</pre>
          <p>Next, rules are added to validate columns. This is done by calling the provider's SetValidationRule method.
          The data field name associated with the column, the implementation of IColumnValidator, and finally,
          which managed views this rule is associated with. If you want all views to be covered by this rule
          don't pass any views to the method.</p>
          <pre lang="cs" numberLines="true" outlining="true" title="Adding column rules to the DxValidateColumnProvider">
   // set a custom validation rule on the 'Name' column which
   // ensures that even trimmed strings must not be blank.
   validateColumn.SetValidationRule("Name", 
      new NotBlankTrimmedColumnValidationRule());
   int minAge = 18;
   // use a ConditionColumnValidator to ensure that
   // the person is of age.
   validateColumn.SetValidationRule("Age",
      new ConditionColumnValidator(String.Format(
      "Age must be greater than {0}.", minAge), 
      ConditionOperator.Greater, minAge), gridView, layoutView);
   // use a CompareAgainstColumnValueValidator to ensure
   // that the 'Name' and 'Code' columns are not the same.
   validateColumn.SetValidationRule("Code", 
      new CompareAgainstColumnValueValidator("Name", 
      CompareControlOperator.NotEquals, 
      "Code must be different then Name."));</pre>
          <p>Finally, you may want to validate a number of columns for consistency. This can be done by assigning a
          rule to the RowValidator property. This rule will run just prior to the row losing focus.</p>
          <pre lang="cs" numberLines="true" outlining="true" title="Assigning the RowValidator property">
   validateColumn.RowValidator = new RowValidationRule();</pre>
          <p>To see how to create a custom validation rule see <a href="CreatingCustomValidator.html">Creating Custom Validation Rules</a></p>
          <p>&nbsp;</p>
          <p>
            <a href="Task-Based Help.html">Back to task-based help.</a>
          </p>
        </div>
      </div>
      <div id="footer">
        <div class="footerLine">
          <img width="100%" height="3px" src="../../icons/footer.gif" title="Footer image" />
        </div>
        <p />
        <div id="DevLynxVersion">
           <p><small>v2009.0.3332.39062 (2009-02-14  21:42:04)</small></p>
        </div>
        <div id="DevLynxCopyright">
           <p>Copyright &copy; 2008-2009, DevLynx</p>
        </div>
      </div>
    </div>
  </body>
</html>
<!-- @SortOrder 5 -->
